// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/efficiency/api/EnergyStatisticApi'

import ListClass from '@api/efficiency/model/EnergyReportFormReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '查询用能报表') {
    const DTO = CORE.grpcDTO(ListClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'energyReportForm', DTO)
    const list = resp.content || []
    return [list.length, list]
  },
  transList(arr, { xData }) {
    arr.forEach((item) => {
      item.dataList = xData.map((_, i) => item[`value${i + 1}`] || 0)
    })
    return arr
  },
}
